package com.songmao.pricecloudapitest.socket.websocket;

import com.alibaba.fastjson.JSON;
import com.songmao.pricecloudapitest.socket.entity.tcp.QuoteSymbolEntity;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;


/**
 * @author Remy
 * @description :
 * @date 2020-04-22 14:45
 */

public class WebSocketCore extends WebSocketClient {

    public WebSocketCore(URI serverUri) {
        super(serverUri);
    }

    @Override
    public void onOpen(ServerHandshake serverHandshake) {
        System.out.println(serverHandshake.getHttpStatus());
        System.out.println(serverHandshake.getHttpStatusMessage());

    }

    @Override
    public void onMessage(String s) {
        //  System.out.println(s);
        QuoteSymbolEntity quoteSymbolEntity = JSON.parseObject(s, QuoteSymbolEntity.class);
        System.out.println(quoteSymbolEntity);
    }

    @Override
    public void onClose(int i, String s, boolean b) {
        System.out.println("已经关闭了");
    }

    @Override
    public void onError(Exception e) {

    }

}

